<?php defined('IN_YuLin') || exit('NO PERMIT!'); ?>
{template index/header}
<link rel="stylesheet" href="static/js/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="static/js/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="static/js/kindeditor/lang/zh_CN.js"></script>
<style>
	.layui-form-item .layui-input-inline{width:600px;}
	.layui-form-item .layui-input-block{ margin-right:100px;}
.send-group{
	width:100%;
	float:left;
	margin-top:10px;
	font-size:12px;
}
.send-group label{
	color:#666;
	float:left;
	width:40px;
	margin-left:8px; 
	cursor: pointer;
}
.level-selectd{	
	color:#0473c1 !important;
}
.view-content{
	    float: left;
        line-height: 32px;
        background: #effff2;
        min-width: 800px;
        min-height: 300px;
        padding: 10px 12px;
}
</style>
<div class="subnav">
    <a href="">首页</a> &gt; <a href="">系统管理</a> &gt; <a href="">站内信编辑</a>
</div>
<div class="x-nav">
	<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
		<i class="layui-icon" style="line-height:30px">ဂ</i>
	</a>
	<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin:3px 5px 0 0;float:right" href="?m={$m}&c={$c}" title="返回">
		<i class="layui-icon" style="line-height:30px">&lt;</i>
	</a>
</div>

<div class="x-body">
	<div class="layui-main">
		<form class="layui-form" action="index.php?m=user&c=letter_add" method="post">
			<input type="hidden" name="id" value="{$letter_id}" />
			<div class="layui-form-item">
				<label class="layui-form-label">收件人：</label>
				<div class="layui-input-inline">
					<input type="text" name="recipient" value="{$arr['recipient']}" {if $letter_id} readonly="readonly" {/if} class="layui-input" style="width:300px;">
					<span style="color:#777;font-size:13px;margin-left:20px;">收件人为空时将为选择的等级推送</span>
				</div>
			</div>	
			{if !$letter_id || $arr['user_grade']}		
			<div class="layui-form-item">
				<label class="layui-form-label">会员等级：</label>
				<div class="layui-input-inline">
				    <div class="send-group" >
				        <label {if in_array(1, explode(",", $arr['user_grade']))} class="level-selectd" {else} class="level-box" {/if}>测试组<input type="checkbox" class="level-box" name="level[]" value="1" style="display:none;"></label>
						<label {if in_array(2, explode(",", $arr['user_grade']))} class="level-selectd" {else} class="level-box" {/if}>黑名单<input type="checkbox" class="level-box" name="level[]" value="2" style="display:none;"></label>
						<label {if in_array(3, explode(",", $arr['user_grade']))} class="level-selectd" {else} class="level-box" {/if}>VIP1<input type="checkbox" class="level-box" name="level[]" value="3" style="display:none;"></label>
						<label {if in_array(4, explode(",", $arr['user_grade']))} class="level-selectd" {else} class="level-box" {/if}>VIP2<input type="checkbox" class="level-box" name="level[]" value="4" style="display:none;"></label>
						<label {if in_array(5, explode(",", $arr['user_grade']))} class="level-selectd" {else} class="level-box" {/if}>VIP3<input type="checkbox" class="level-box" name="level[]" value="5" style="display:none;"></label>
						<label {if in_array(6, explode(",", $arr['user_grade']))} class="level-selectd" {else} class="level-box" {/if}>VIP4<input type="checkbox" class="level-box" name="level[]" value="6" style="display:none;"></label>
						<label {if in_array(7, explode(",", $arr['user_grade']))} class="level-selectd" {else} class="level-box" {/if}>VIP5<input type="checkbox" class="level-box" name="level[]" value="7" style="display:none;"></label>
						<label {if in_array(8, explode(",", $arr['user_grade']))} class="level-selectd" {else} class="level-box" {/if}>VIP6<input type="checkbox" class="level-box" name="level[]" value="8" style="display:none;"></label>
						<label {if in_array(9, explode(",", $arr['user_grade']))} class="level-selectd" {else} class="level-box" {/if}>VIP7<input type="checkbox" class="level-box" name="level[]" value="9" style="display:none;"></label>
						<label {if in_array(10, explode(",", $arr['user_grade']))} class="level-selectd" {else} class="level-box" {/if}>VIP8<input type="checkbox" class="level-box" name="level[]" value="10" style="display:none;"></label>
						<label {if in_array(11, explode(",", $arr['user_grade']))} class="level-selectd" {/if}>VIP9<input type="checkbox" class="level-box" name="level[]" value="11" style="display:none;"></label>
				     </div>		
				</div>
				<div class="layui-form-mid layui-word-aux"></div>
			</div>
			{/if}	
			<div class="layui-form-item">
				<label class="layui-form-label">标题：</label>
				<div class="layui-input-inline">
					<input type="text" name="title" value="{$arr['title']}" {if $letter_id} readonly="readonly" {/if} required="true"  autocomplete="off" class="layui-input" style="width:300px;">
					<span style="color:#777;font-size:13px;margin-left:20px;">*</span>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">内容描述：</label>
				{if !$letter_id}
				<div class="layui-input-inline">
					<textarea name="content" style="width:800px;height:500px;" ></textarea>
				</div>
				{else}
				<div class="layui-input-inline">
					<div class="view-content">{htmlspecialchars_decode($arr[content])}</div>
				</div>
				{/if}
			</div>
			{if !$letter_id}
			<div class="layui-form-item">
				<div class="layui-input-block" style="margin-left:150px;">
					<a class="layui-btn" href="#" onClick="javascript:history.back(-1)">返回</a>
					<button style="margin-left:20px;" class="layui-btn" type="submit">确定</button>
				</div>
			</div>
			{/if}
		</form>
	</div>
</div>
<script type="text/javascript">
    var editor;
    KindEditor.ready(function(K) {
    	editor = K.create('textarea[name="content"]', {
    		allowFileManager : true
    	});
    }); 

	$(".level-box").click(function (){
		 if($(this).is(":checked")){
			$(this).parent().addClass("level-selectd");
		}else{
			$(this).parent().removeClass("level-selectd");
		}
	});

</script>
{template index/footer}